<template>
  <div
    class="form-im-preview disabled"
    :style="{
      right: isOnlyPreview
        ? 'calc((100% - 437px - 208px - 400px) / 2 + 460px)'
        : 'calc((100% - 430px - 220px - 375px) / 2 + 440px)',
      bottom: isOnlyPreview ? 'calc((100% - 722px) / 2 + 180px)' : '140px',
    }"
  >
    <div class="im-preview">
      <img :src="customerSerImage" alt="">
    </div>
    
    <div class="form-design-operation" v-if="!isOnlyPreview">
      <div class="form-design-preview-delete form-design-preview-btn" @click="deleteField">
        <el-tooltip
          class="item"
          effect="dark"
          placement="top"
          content="删除在线客服"
        >
          <i class="iconfont icon-shanchu-copy"></i>
        </el-tooltip>
      </div>
    </div>
      
  </div>
</template>

<script>
import { findComponentUpward } from '@src/util/assist'
import { previewProps } from '@src/mform/components/props'
import { getOssUrl } from '@src/util/assets'
const customerSerImage = getOssUrl('/customer_ser.png')
export default {
  name: 'form-im-preview',
  props: {
    ...previewProps
  },
  data() {
    return {
      customerSerImage
    }
  },
  computed: {
    formPreviewComponent() {
      return findComponentUpward(this, 'mform-preview')
    },
    isOnlyPreview() {
      return this.formPreviewComponent.isOnlyPreview || false
    }
  },
  methods: {
    deleteField() {
      this.formPreviewComponent.deleteField(this.field)
    }
  }
}
</script>

<style lang="scss">
.form-im-preview {
  position: fixed;
  // right: calc(50% - 60px);
  // top: 650px;
  // top: none;
  z-index: 1;
  .im-preview {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    img {
      width: 56px;
      height: 56px;
      // border: 1px solid red;
      border-radius: 50%;
    }
  }
  .form-design-operation {
    visibility: visible;
    display: none;
  }
  &:hover {
    .form-design-operation {
      display: block;
    }
  }
}
</style>
